package socket;

import java.net.Socket;
import java.io.*;

/**
 * 
 * @author pfister@lgi2p 07/11/28
 *
 */
public class ClientOutputThread extends BaseThread implements Protocol {

	public ClientOutputThread(Socket connexion, BaseClient client) {
		super(connexion, client);
	}

	public void run() {
	
		try {
			
			client.inp = new InputStreamReader(System.in);
			BufferedReader kbd = new BufferedReader(client.inp);
			PrintWriter socketWriter = new PrintWriter(
					socket.getOutputStream(), true);
			socketWriter.println(NEWCLIENT + client.getName());
			//socketWriter.println();
			
			while (!client.stop) {
				/*
				String ligne = kbd.readLine();
				if (ligne.contains(QUIT.trim()))
					client.stop = true;
				if (ligne != null)
					socketWriter.println(ligne+EOM);//+" [eol]");
				*/
			    try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					client.log("error " + e);
				}
			}
			client.stop();
			socket.close();
		} catch (IOException e) {
			client.log("error " + e);
		}

	}

}